package com.dhcc.DRGsHosp.core.domain;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

import org.openkoala.koala.commons.domain.KoalaLegacyEntity;

/** 
 * @title		:Medicalrecord.java
 * @description	:
 * @author		:lileizheng
 * @date		:2015年4月2日
 * @version     :1.0
 * @copyright   :DHCC 2013-2014 
 */
@Entity
@Table (name = "T_MEDICALRECORD", schema = "DRGs")

public class MedicalRecord extends KoalaLegacyEntity {

private static final long serialVersionUID = -2700241427681303048L;
//ID
@Id
@Column(name = "ID" , nullable = false)
private String id;

//就诊记录ID
@Column(name = "RECORD_ID")
private String recordId;

//主索引ID
@Column(name = "PATIENT_ID")
private String patientId;

//病案号
@Column(name = "MR_NO")
private String mrNo;

//姓名
@Column(name = "PATIENT_NAME")
private String patientName;

//性别
@Column(name = "SEX")
private String sex;

//年龄岁
@Column(name = "AGE_YEAR")
private Double ageYear;

//年龄月
@Column(name = "AGE_MONTH")
private Double ageMonth;

//年龄天
@Column(name = "AGE_DAYS")
private Double ageDays;

//婚姻状况
@Column(name = "MARRIAGE")
private String marriage;

//出生日期
@Column(name = "DAY_OF_BIRTH")
private Date dayOfbirth;

//入院日期
@Column(name = "IN_DATE")
private Date inDate;

//入院科室代码
@Column(name = "IN_DEP_CODE")
private String inDepcode;

//入院科室
@Column(name = "IN_DEP")
private String inDep;

//入院病区代码
@Column(name = "IN_WARD_CODE")
private String inWardcode;

//入院病区
@Column(name = "IN_WARD")
private String inWard;

//离院方式,1:医嘱离院; 2:医嘱转院; 3:医嘱转飞升服务机构或乡镇卫生院; 4:非医嘱离院; 5:死亡; 9:其他
@Column(name = "OUT_WAY")
private String outWay;

//入院途径
@Column(name = "IN_WAY")
private String inWay;

//住院次数
@Column(name = "IP_COUNT")
private Double ipCount;

//门急诊诊断编码
@Column(name = "OP_DIAGNOSIS_CODE")
private String opDiagnosiscode;

//门急诊诊断
@Column(name = "OP_DIAGNOSIS")
private String opDiagnosis;

//出院日期
@Column(name = "OUT_DATE")
private Date outDate;

//出院科室代码
@Column(name = "OUT_DEP_CODE")
private String outDepcode;

//出院科室
@Column(name = "OUT_DEP")
private String outDep;

//入院病区代码
@Column(name = "OUT_WARD_CODE")
private String outWardcode;

//入院病区
@Column(name = "OUT_WARD")
private String outWard;

//科主任代码
@Column(name = "DEP_MASTER_CODE")
private String depMastercode;

//科主任
@Column(name = "DEP_MASTER")
private String depMaster;

//主任医师代码
@Column(name = "PROTOMEDICUS_CODE")
private String protomedicusCode;

//主任医师
@Column(name = "PROTOMEDICUS")
private String protomedicus;

//主治医师代码
@Column(name = "PHYSICIAN_CODE")
private String physicianCode;

//主治医师
@Column(name = "PHYSICIAN")
private String physician;

//住院医师代码
@Column(name = "RESIDENT_DOCTOR_CODE")
private String residentDoctorcode;

//住院医师
@Column(name = "RESIDENT_DOCTOR")
private String residentDoctor;

//进修医师代码
@Column(name = "PHYSICIAN_LEARN_CODE")
private String physicianLearncode;

//进修医师
@Column(name = "PHYSICIAN_LEARN")
private String physicianLearn;

//实习医师代码
@Column(name = "INTERN_CODE")
private String internCode;

//实习医师
@Column(name = "INTERN")
private String intern;

//责任护士代码
@Column(name = "NURSE_CODE")
private String nurseCode;

//责任护士
@Column(name = "NURSE")
private String nurse;

//责任护士代码
@Column(name = "CODER_CODE")
private String coderCode;

//责任护士
@Column(name = "CODER")
private String coder;

//医疗付费方式
@Column(name = "PAYMENT")
private String payment;

//总费用
@Column(name = "COSTAMOUNT")
private Double costamount;

//自付费用
@Column(name = "COSTSELF")
private Double costself;

//危重等级
@Column(name = "DANGERLEVEL")
private String dangerlevel;

//药品费用
@Column(name = "DRUGCOST")
private Double drugcost;

//主诊组
@Column(name = "PARGROUP_NAME")
private String pargroupName;

//主要诊断代码
@Column(name = "DIAGNOSE_CODE_MAIN")
private String diagnoseCodemain;

//主要诊断描述
@Column(name = "DIAGNOSE_DESS_MAIN")
private String diagnoseDessmain;

//新生儿体重
@Column(name = "NEWBORN_WEIGHT")
private Double newbornWeight;

//新生儿天数
@Column(name = "NEWBORN_DAYS")
private Double newbornDays;

//呼吸机使用时间
@Column(name = "VENTILATOR_HOUR")
private Double ventilatorHour;

//住院天数
@Column(name = "IN_DAYS")
private Double inDays;

//材料费
@Column(name = "MATERIALCOST")
private Double materialcost;

//卫统标识
@Column(name = "WTMARK")
private Double wtmark;

//病案质量
@Column(name = "MR_QUALITY")
private String mrQuality;

//转科科室
@Column(name = "TRANS_DEP_DESC")
private String transDepDesc;

//是否感染
@Column(name = "INFECTION_CASE")
private String infectionCase;

//是否抢救成功
@Column(name = "RESCUE_SUCCESS_CASE")
private String rescueSuccessCase;

//14天是否再住院
@Column(name = "DAYS_CASE_14")
private String dayscase14;

//31天是否再住院
@Column(name = "DAYS_CASE_31")
private String dayscase31;

//是否手术患者
@Column(name = "OPERATION_CASE")
private String operationcase;

//是否手术并发症
@Column(name = "COMPLICATIONS_CASE")
private String complicationscase;

//是否发生不良事件
@Column(name = "ADVERSEEVENTS_CASE")
private String adverseeventscase;

//是否使用抗菌药物
@Column(name = "USE_ANTI_CASE")
private String useanticase;

//是否临床路径患者
@Column(name = "CPW_CASE")
private String cpwcase;

//手术并发症
@Column(name = "COMPLICATIONS")
private String complications;


public String getOperationcase() {
	return operationcase;
}

public void setOperationcase(String operationcase) {
	this.operationcase = operationcase;
}

public String getTransDepDesc() {
	return transDepDesc;
}

public void setTransDepDesc(String transDepDesc) {
	this.transDepDesc = transDepDesc;
}

/* (non-Javadoc)
 * @see org.dayatang.domain.Entity#getId()
 */
public String getId() {
	// TODO Auto-generated method stub
	return id;
}


/**
 * @return the complications
 */
public String getComplications() {
	return complications;
}

/**
 * @param complications the complications to set
 */
public void setComplications(String complications) {
	this.complications = complications;
}

/**
 * @return the infectionCase
 */
public String getInfectionCase() {
	return infectionCase;
}

/**
 * @param infectionCase the infectionCase to set
 */
public void setInfectionCase(String infectionCase) {
	this.infectionCase = infectionCase;
}

/**
 * @return the rescueSuccessCase
 */
public String getRescueSuccessCase() {
	return rescueSuccessCase;
}

/**
 * @return the outWardcode
 */
public String getOutWardcode() {
	return outWardcode;
}

/**
 * @param outWardcode the outWardcode to set
 */
public void setOutWardcode(String outWardcode) {
	this.outWardcode = outWardcode;
}

/**
 * @return the outWard
 */
public String getOutWard() {
	return outWard;
}

/**
 * @param outWard the outWard to set
 */
public void setOutWard(String outWard) {
	this.outWard = outWard;
}

/**
 * @param rescueSuccessCase the rescueSuccessCase to set
 */
public void setRescueSuccessCase(String rescueSuccessCase) {
	this.rescueSuccessCase = rescueSuccessCase;
}



public String getMrQuality() {
	return mrQuality;
}

public void setMrQuality(String mrQuality) {
	this.mrQuality = mrQuality;
}

/* (non-Javadoc)
 * @see org.openkoala.koala.commons.domain.KoalaBaseEntity#businessKeys()
 */
@Override
public String[] businessKeys() {
	// TODO Auto-generated method stub
	return null;
}

public String getRecordId() {
	return recordId;
}

/**
 * @return the wtmark
 */
public Double getWtmark() {
	return wtmark;
}

/**
 * @param wtmark the wtmark to set
 */
public void setWtmark(Double wtmark) {
	this.wtmark = wtmark;
}

public void setRecordId(String recordId) {
	this.recordId = recordId;
}

public String getPatientId() {
	return patientId;
}

public void setPatientId(String patientId) {
	this.patientId = patientId;
}

public String getMrNo() {
	return mrNo;
}

public void setMrNo(String mrNo) {
	this.mrNo = mrNo;
}

public String getPatientName() {
	return patientName;
}

public void setPatientName(String patientName) {
	this.patientName = patientName;
}

public String getSex() {
	return sex;
}

public void setSex(String sex) {
	this.sex = sex;
}

public Double getAgeYear() {
	return ageYear;
}

public void setAgeYear(Double ageYear) {
	this.ageYear = ageYear;
}

public Double getAgeMonth() {
	return ageMonth;
}

public void setAgeMonth(Double ageMonth) {
	this.ageMonth = ageMonth;
}

public Double getAgeDays() {
	return ageDays;
}

public void setAgeDays(Double ageDays) {
	this.ageDays = ageDays;
}

public String getMarriage() {
	return marriage;
}

public void setMarriage(String marriage) {
	this.marriage = marriage;
}

public Date getDayOfbirth() {
	return dayOfbirth;
}

public void setDayOfbirth(Date dayOfbirth) {
	this.dayOfbirth = dayOfbirth;
}

public Date getInDate() {
	return inDate;
}

public void setInDate(Date inDate) {
	this.inDate = inDate;
}

public String getInDepcode() {
	return inDepcode;
}

public void setInDepcode(String inDepcode) {
	this.inDepcode = inDepcode;
}

public String getInDep() {
	return inDep;
}

public void setInDep(String inDep) {
	this.inDep = inDep;
}

public String getInWardcode() {
	return inWardcode;
}

public void setInWardcode(String inWardcode) {
	this.inWardcode = inWardcode;
}

public String getInWard() {
	return inWard;
}

public void setInWard(String inWard) {
	this.inWard = inWard;
}

public String getOutWay() {
	return outWay;
}

public void setOutWay(String outWay) {
	this.outWay = outWay;
}

public String getInWay() {
	return inWay;
}

public void setInWay(String inWay) {
	this.inWay = inWay;
}

public Double getIpCount() {
	return ipCount;
}

public void setIpCount(Double ipCount) {
	this.ipCount = ipCount;
}

public String getOpDiagnosiscode() {
	return opDiagnosiscode;
}

public void setOpDiagnosiscode(String opDiagnosiscode) {
	this.opDiagnosiscode = opDiagnosiscode;
}

public String getOpDiagnosis() {
	return opDiagnosis;
}

public void setOpDiagnosis(String opDiagnosis) {
	this.opDiagnosis = opDiagnosis;
}

public Date getOutDate() {
	return outDate;
}

public void setOutDate(Date outDate) {
	this.outDate = outDate;
}

public String getOutDepcode() {
	return outDepcode;
}

public void setOutDepcode(String outDepcode) {
	this.outDepcode = outDepcode;
}

public String getOutDep() {
	return outDep;
}

public void setOutDep(String outDep) {
	this.outDep = outDep;
}

public String getDepMastercode() {
	return depMastercode;
}

public void setDepMastercode(String depMastercode) {
	this.depMastercode = depMastercode;
}

public String getDepMaster() {
	return depMaster;
}

public void setDepMaster(String depMaster) {
	this.depMaster = depMaster;
}

public String getProtomedicusCode() {
	return protomedicusCode;
}

public void setProtomedicusCode(String protomedicusCode) {
	this.protomedicusCode = protomedicusCode;
}

public String getProtomedicus() {
	return protomedicus;
}

public void setProtomedicus(String protomedicus) {
	this.protomedicus = protomedicus;
}

public String getPhysicianCode() {
	return physicianCode;
}

public void setPhysicianCode(String physicianCode) {
	this.physicianCode = physicianCode;
}

public String getPhysician() {
	return physician;
}

public void setPhysician(String physician) {
	this.physician = physician;
}

public String getResidentDoctorcode() {
	return residentDoctorcode;
}

public void setResidentDoctorcode(String residentDoctorcode) {
	this.residentDoctorcode = residentDoctorcode;
}

public String getResidentDoctor() {
	return residentDoctor;
}

public void setResidentDoctor(String residentDoctor) {
	this.residentDoctor = residentDoctor;
}

public String getPhysicianLearncode() {
	return physicianLearncode;
}

public void setPhysicianLearncode(String physicianLearncode) {
	this.physicianLearncode = physicianLearncode;
}

public String getPhysicianLearn() {
	return physicianLearn;
}

public void setPhysicianLearn(String physicianLearn) {
	this.physicianLearn = physicianLearn;
}

public String getInternCode() {
	return internCode;
}

public void setInternCode(String internCode) {
	this.internCode = internCode;
}

public String getIntern() {
	return intern;
}

public void setIntern(String intern) {
	this.intern = intern;
}

public String getNurseCode() {
	return nurseCode;
}

public void setNurseCode(String nurseCode) {
	this.nurseCode = nurseCode;
}

public String getNurse() {
	return nurse;
}

public void setNurse(String nurse) {
	this.nurse = nurse;
}

public String getCoderCode() {
	return coderCode;
}

public void setCoderCode(String coderCode) {
	this.coderCode = coderCode;
}

public String getCoder() {
	return coder;
}

public void setCoder(String coder) {
	this.coder = coder;
}

public String getPayment() {
	return payment;
}

public void setPayment(String payment) {
	this.payment = payment;
}

public Double getCostamount() {
	return costamount;
}

public void setCostamount(Double costamount) {
	this.costamount = costamount;
}

public Double getCostself() {
	return costself;
}

public void setCostself(Double costself) {
	this.costself = costself;
}

public String getDangerlevel() {
	return dangerlevel;
}

public void setDangerlevel(String dangerlevel) {
	this.dangerlevel = dangerlevel;
}

public Double getDrugcost() {
	return drugcost;
}

public void setDrugcost(Double drugcost) {
	this.drugcost = drugcost;
}

public String getPargroupName() {
	return pargroupName;
}

public void setPargroupName(String pargroupName) {
	this.pargroupName = pargroupName;
}

public String getDiagnoseCodemain() {
	return diagnoseCodemain;
}

public void setDiagnoseCodemain(String diagnoseCodemain) {
	this.diagnoseCodemain = diagnoseCodemain;
}

public String getDiagnoseDessmain() {
	return diagnoseDessmain;
}

public void setDiagnoseDessmain(String diagnoseDessmain) {
	this.diagnoseDessmain = diagnoseDessmain;
}

public Double getNewbornWeight() {
	return newbornWeight;
}

public void setNewbornWeight(Double newbornWeight) {
	this.newbornWeight = newbornWeight;
}

public Double getNewbornDays() {
	return newbornDays;
}

public void setNewbornDays(Double newbornDays) {
	this.newbornDays = newbornDays;
}

public Double getVentilatorHour() {
	return ventilatorHour;
}

public void setVentilatorHour(Double ventilatorHour) {
	this.ventilatorHour = ventilatorHour;
}

public Double getInDays() {
	return inDays;
}

public void setInDays(Double inDays) {
	this.inDays = inDays;
}

public Double getMaterialcost() {
	return materialcost;
}

public void setMaterialcost(Double materialcost) {
	this.materialcost = materialcost;
}

public void setId(String id) {
	this.id = id;
}


public String getDayscase14() {
	return dayscase14;
}

public void setDayscase14(String dayscase14) {
	this.dayscase14 = dayscase14;
}

public String getDayscase31() {
	return dayscase31;
}

public void setDayscase31(String dayscase31) {
	this.dayscase31 = dayscase31;
}

public String getComplicationscase() {
	return complicationscase;
}

public void setComplicationscase(String complicationscase) {
	this.complicationscase = complicationscase;
}

public String getAdverseeventscase() {
	return adverseeventscase;
}

public void setAdverseeventscase(String adverseeventscase) {
	this.adverseeventscase = adverseeventscase;
}

public String getUseanticase() {
	return useanticase;
}

public void setUseanticase(String useanticase) {
	this.useanticase = useanticase;
}

public String getCpwcase() {
	return cpwcase;
}

public void setCpwcase(String cpwcase) {
	this.cpwcase = cpwcase;
}


/**
 * @param id
 * @param recordId
 * @param patientId
 * @param mrNo
 * @param patientName
 * @param sex
 * @param ageYear
 * @param ageMonth
 * @param ageDays
 * @param marriage
 * @param dayOfbirth
 * @param inDate
 * @param inDepcode
 * @param inDep
 * @param inWardcode
 * @param inWard
 * @param outWay
 * @param inWay
 * @param ipCount
 * @param opDiagnosiscode
 * @param opDiagnosis
 * @param outDate
 * @param outDepcode
 * @param outDep
 * @param outWardcode
 * @param outWard
 * @param depMastercode
 * @param depMaster
 * @param protomedicusCode
 * @param protomedicus
 * @param physicianCode
 * @param physician
 * @param residentDoctorcode
 * @param residentDoctor
 * @param physicianLearncode
 * @param physicianLearn
 * @param internCode
 * @param intern
 * @param nurseCode
 * @param nurse
 * @param payment
 * @param costamount
 * @param costself
 * @param dangerlevel
 * @param drugcost
 * @param pargroupName
 * @param diagnoseCodemain
 * @param diagnoseDessmain
 * @param newbornWeight
 * @param newbornDays
 * @param ventilatorHour
 * @param inDays
 * @param materialcost
 * @param wtmark
 * @param mrQuality
 * @param transDepDesc
 * @param infectionCase
 * @param rescueSuccessCase
 * @param dayscase14
 * @param dayscase31
 * @param operationcase
 * @param complicationscase
 * @param adverseeventscase
 * @param useanticase
 * @param cpwcase
 */
public MedicalRecord(String id, String recordId, String patientId, String mrNo, String patientName, String sex,
		Double ageYear, Double ageMonth, Double ageDays, String marriage, Date dayOfbirth, Date inDate,
		String inDepcode, String inDep, String inWardcode, String inWard, String outWay, String inWay, Double ipCount,
		String opDiagnosiscode, String opDiagnosis, Date outDate, String outDepcode, String outDep, String outWardcode,
		String outWard, String depMastercode, String depMaster, String protomedicusCode, String protomedicus,
		String physicianCode, String physician, String residentDoctorcode, String residentDoctor,
		String physicianLearncode, String physicianLearn, String internCode, String intern, String nurseCode,
		String nurse, String payment, Double costamount, Double costself, String dangerlevel, Double drugcost,
		String pargroupName, String diagnoseCodemain, String diagnoseDessmain, Double newbornWeight, Double newbornDays,
		Double ventilatorHour, Double inDays, Double materialcost, Double wtmark, String mrQuality, String transDepDesc,
		String infectionCase, String rescueSuccessCase, String dayscase14, String dayscase31, String operationcase,
		String complicationscase, String adverseeventscase, String useanticase, String cpwcase) {
	super();
	this.id = id;
	this.recordId = recordId;
	this.patientId = patientId;
	this.mrNo = mrNo;
	this.patientName = patientName;
	this.sex = sex;
	this.ageYear = ageYear;
	this.ageMonth = ageMonth;
	this.ageDays = ageDays;
	this.marriage = marriage;
	this.dayOfbirth = dayOfbirth;
	this.inDate = inDate;
	this.inDepcode = inDepcode;
	this.inDep = inDep;
	this.inWardcode = inWardcode;
	this.inWard = inWard;
	this.outWay = outWay;
	this.inWay = inWay;
	this.ipCount = ipCount;
	this.opDiagnosiscode = opDiagnosiscode;
	this.opDiagnosis = opDiagnosis;
	this.outDate = outDate;
	this.outDepcode = outDepcode;
	this.outDep = outDep;
	this.outWardcode = outWardcode;
	this.outWard = outWard;
	this.depMastercode = depMastercode;
	this.depMaster = depMaster;
	this.protomedicusCode = protomedicusCode;
	this.protomedicus = protomedicus;
	this.physicianCode = physicianCode;
	this.physician = physician;
	this.residentDoctorcode = residentDoctorcode;
	this.residentDoctor = residentDoctor;
	this.physicianLearncode = physicianLearncode;
	this.physicianLearn = physicianLearn;
	this.internCode = internCode;
	this.intern = intern;
	this.nurseCode = nurseCode;
	this.nurse = nurse;
	this.payment = payment;
	this.costamount = costamount;
	this.costself = costself;
	this.dangerlevel = dangerlevel;
	this.drugcost = drugcost;
	this.pargroupName = pargroupName;
	this.diagnoseCodemain = diagnoseCodemain;
	this.diagnoseDessmain = diagnoseDessmain;
	this.newbornWeight = newbornWeight;
	this.newbornDays = newbornDays;
	this.ventilatorHour = ventilatorHour;
	this.inDays = inDays;
	this.materialcost = materialcost;
	this.wtmark = wtmark;
	this.mrQuality = mrQuality;
	this.transDepDesc = transDepDesc;
	this.infectionCase = infectionCase;
	this.rescueSuccessCase = rescueSuccessCase;
	this.dayscase14 = dayscase14;
	this.dayscase31 = dayscase31;
	this.operationcase = operationcase;
	this.complicationscase = complicationscase;
	this.adverseeventscase = adverseeventscase;
	this.useanticase = useanticase;
	this.cpwcase = cpwcase;
}

/**
 * 
 */
public MedicalRecord() {
	super();
	// TODO Auto-generated constructor stub
}

public static String getLatestDate() {
	String datetoString = getRepository().createSqlQuery("SELECT MAX(OUT_DATE) FROM DRGs.T_MEDICALRECORD ").singleResult().toString().substring(0, 10);
	return datetoString;
}

}

